/**
 * All rights Reserved, Designed By junglead.cn
 * @package cn.junglead.common.signature
 * @title SignatureInfo.java
 * @date 2020年12月11日
 */
package cn.junglead.common.signature;

import java.security.PrivateKey;
import java.security.cert.Certificate;

import com.itextpdf.text.pdf.PdfSignatureAppearance;
import com.itextpdf.text.pdf.security.DigestAlgorithms;
import com.itextpdf.text.pdf.security.MakeSignature;

/**
 * 电子签章配置对象
 * @author Gary.Wang
 * @version 1.0
 */
public final class SignatureInfo {
	/**
	 * 1.1 签章理由
	 */
	private String reason; //理由
	
	/**
	 * 1.2 签章位置
	 */
    private String location;//位置
    
    /**
     * 1.3 摘要类型
     */
    private String digestAlgorithm;//摘要类型
    
    /**
     * 1.4 图章了路径
     */
    private String imagePath;//图章路径
    
    /**
     * 1.5 pdf中的表单域名字
     */
    private String fieldName;//表单域名称
    
    /**
     * 1.6 证书链
     */
    private Certificate[] chain;//证书链
    
    /**
     * 1.7 私钥对象
     */
    private PrivateKey pk;//私钥
    
    /**
     * 1.8 批准签章等级
     */
    private int certificationLevel = 0; //批准签章
    
    /**
     * 1.9 签章类型
     */
    private PdfSignatureAppearance.RenderingMode renderingMode;//表现形式：仅描述，仅图片，图片和描述，签章者和描述
    
    /**
     * 1.10 签章支持标准
     */
    private MakeSignature.CryptoStandard subfilter;//支持标准，CMS,CADES
    
    /**
     * 1.11.1 左下角x轴坐标，left bottom x
     */
    private int lbx;
    
    /**
     * 1.11.2 左下角y轴坐标，left bottom y
     */
    private int lby;
    
    /**
     * 1.11.3 右上角x轴坐标，right top x
     */
    private int rtx;
    
    /**
     * 1.11.4 右上角y轴坐标，right top y
     */
    private int rty;
    
    
    /**
     * 
     * 1 无参构造函数
     */
    public SignatureInfo() {
    	this.setCertificationLevel(PdfSignatureAppearance.NOT_CERTIFIED);
    	this.setDigestAlgorithm(DigestAlgorithms.SHA1);
    	this.setRenderingMode(PdfSignatureAppearance.RenderingMode.GRAPHIC);
    }
    
    /**
     * 
     * 2 设置初始秘钥和证书链的构造参数
     * @param pk 秘钥对象
     * @param chain 证书链
     */
    public SignatureInfo(PrivateKey pk, Certificate[] chain) {
    	this.setPk(pk);
    	this.setChain(chain);
    	this.setCertificationLevel(PdfSignatureAppearance.NOT_CERTIFIED);
    	this.setDigestAlgorithm(DigestAlgorithms.SHA1);
    	this.setRenderingMode(PdfSignatureAppearance.RenderingMode.GRAPHIC);
    }

	/**
	 * @return the reason
	 */
	public String getReason() {
		return reason;
	}

	/**
	 * @param reason the reason to set
	 */
	public void setReason(String reason) {
		this.reason = reason;
	}

	/**
	 * @return the location
	 */
	public String getLocation() {
		return location;
	}

	/**
	 * @param location the location to set
	 */
	public void setLocation(String location) {
		this.location = location;
	}

	/**
	 * @return the digestAlgorithm
	 */
	public String getDigestAlgorithm() {
		return digestAlgorithm;
	}

	/**
	 * @param digestAlgorithm the digestAlgorithm to set
	 */
	public void setDigestAlgorithm(String digestAlgorithm) {
		this.digestAlgorithm = digestAlgorithm;
	}

	/**
	 * @return the imagePath
	 */
	public String getImagePath() {
		return imagePath;
	}

	/**
	 * @param imagePath the imagePath to set
	 */
	public void setImagePath(String imagePath) {
		this.imagePath = imagePath;
	}

	/**
	 * @return the fieldName
	 */
	public String getFieldName() {
		return fieldName;
	}

	/**
	 * @param fieldName the fieldName to set
	 */
	public void setFieldName(String fieldName) {
		this.fieldName = fieldName;
	}

	/**
	 * @return the chain
	 */
	public Certificate[] getChain() {
		return chain;
	}

	/**
	 * @param chain the chain to set
	 */
	public void setChain(Certificate[] chain) {
		this.chain = chain;
	}

	/**
	 * @return the pk
	 */
	public PrivateKey getPk() {
		return pk;
	}

	/**
	 * @param pk the pk to set
	 */
	public void setPk(PrivateKey pk) {
		this.pk = pk;
	}

	/**
	 * @return the certificationLevel
	 */
	public int getCertificationLevel() {
		return certificationLevel;
	}

	/**
	 * @param certificationLevel the certificationLevel to set
	 */
	public void setCertificationLevel(int certificationLevel) {
		this.certificationLevel = certificationLevel;
	}

	/**
	 * @return the renderingMode
	 */
	public PdfSignatureAppearance.RenderingMode getRenderingMode() {
		return renderingMode;
	}

	/**
	 * @param renderingMode the renderingMode to set
	 */
	public void setRenderingMode(PdfSignatureAppearance.RenderingMode renderingMode) {
		this.renderingMode = renderingMode;
	}

	/**
	 * @return the subfilter
	 */
	public MakeSignature.CryptoStandard getSubfilter() {
		return subfilter;
	}

	/**
	 * @param subfilter the subfilter to set
	 */
	public void setSubfilter(MakeSignature.CryptoStandard subfilter) {
		this.subfilter = subfilter;
	}

	/**
	 * @return the lbx
	 */
	public int getLbx() {
		return lbx;
	}

	/**
	 * @param lbx the lbx to set
	 */
	public void setLbx(int lbx) {
		this.lbx = lbx;
	}

	/**
	 * @return the lby
	 */
	public int getLby() {
		return lby;
	}

	/**
	 * @param lby the lby to set
	 */
	public void setLby(int lby) {
		this.lby = lby;
	}

	/**
	 * @return the rtx
	 */
	public int getRtx() {
		return rtx;
	}

	/**
	 * @param rtx the rtx to set
	 */
	public void setRtx(int rtx) {
		this.rtx = rtx;
	}

	/**
	 * @return the rty
	 */
	public int getRty() {
		return rty;
	}

	/**
	 * @param rty the rty to set
	 */
	public void setRty(int rty) {
		this.rty = rty;
	}
}
